package cn.tedu.blog.server.controller.api;

import cn.tedu.blog.server.pojo.vo.ApiArticleListItemVO;
import cn.tedu.blog.server.pojo.vo.ArticleListItemVO;
import cn.tedu.blog.server.service.IArticleService;
import cn.tedu.blog.server.utils.JsonPage;
import cn.tedu.blog.server.utils.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/articles")
@Api(tags = "前台文章模块")
public class ApiArticleController {
    @Autowired
    private IArticleService articleService;
    
    @GetMapping("/list/{categoryId}")
    @ApiOperation("根据分类id分页查询文章列表")
    public JsonResult listArticlesByCategoryId(@PathVariable Long categoryId, Integer page, Integer pageSize) {
        JsonPage<ApiArticleListItemVO> list = articleService.listArticlesByCategoryId(categoryId, page, pageSize);
        return JsonResult.ok(list);
    }
}
